Calender coding calender coding
Do you want c program for calender that will be upto 2^32 years or very large year then you are at right place.Their is also given the logic or calculation part behind this great calender.So here are the three links given first of which is logic or calculation part,second is c++ code which can be compiled under Dev c++ , you can add small changes so it can run under other compilers.If you are beginner then you find this as good exercise because it contains large number of concepts are used in these program.Or you can develop some other code with slight changes in the original code that it is an enhanced version of the original program.Third link is the exe file compiled using Dev c++ compiler. For your quick review we also explained the logic further which is as follows To find the day of particular day you have to calculate the number of odd days follow the following procedure:
1)First find the remainder of previous year when divided by 400(Because there is no odd days in 400 year)

2)Then reduce this less than 100 years by removing 100,200,300 year from the remainder and count the odd
odd days as follows Year Odd day
100 5
200 3
300 1
3)After that calculate number of leap year by dividing it by 4
Then calculate number of odd days using following formula
Odd day's=(2xno. of leap year)+(no. of non-leap year)
4)If number of odd days is more than 7 then reduce it to less than 7 by substacting multiple of 7
in any of the following steps
5)This is number of odd day's of previous year to calculate odd day's of month by summing upto previous
month odd days
i)For non-leap year:
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
3 0 3 2 3 2 3 3 2 3 2 3
i)For leap year:
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
3 1 3 2 3 2 3 3 2 3 2 3
(Note:leap year is a year which is divisible by 4 and it is not century year and if it is century year
then it is leap year if it is multiple of 400 otherwise not i.e. 2012 is leap year as it is divisible by 4
also 2000 is leap year because though it is century year it is multiple of 400 but 1900 and 2100 are not)
6)After calculate number of odd day's of particular day of month ex. 13 odd day's will be 6 because
13-7=6(less than 7)
7)After calculating all odd day's add odd day's of year,month,day of month and reduce it below 7 finally
using odd day's you have got you can find day by following table
Sun Mon Tue Wed Thr Fri Sat
0 1 2 3 4 5 6
Example 04/09/2013
2012(previous year)-(400x5)=2012-2000=12
12/4=3 so there are 3 leap year and 9 leap year so odd day's of year is
=(2x3)+9=6+9=15
as number odd day's is greater than 7 so we have to reduce it such that it is less than 7
=15-(7x2)=1
as 9th month is september we have to add odd day's upto 8th month i.e. 3+0+3+2+3+2+3+3=19
=5(odd day's less than 7)
and day of month is 4 so finaly odd day is given by
= odd day's of previous year+odd day's of previous month+odd day's of day of month=1+5+4=1=3 using table in step 7 we got that on this day there is wednesday